import {
	msg
} from "@/utils/tool.js"
import {
	BASE_URL
} from "@/config/index.js"

const upload = (tempFilePaths) => {
	return new Promise((resolve) => {
		uni.uploadFile({
			url: BASE_URL + '/infra/file/upload',
			filePath: tempFilePaths,
			name: 'file',
			success: (uploadFileRes) => {
				const data = JSON.parse(uploadFileRes.data);
				if (data.code === 0) {
					resolve(data)
				} else msg("上传失败")
			}
		});
	})
}

export default upload